﻿@page "/friendlinks"

@if (friendlinks == null)
{
    <Loading />
}
else
{
    <div class="post-wrap categories">
        <h2 class="post-title">-&nbsp;FriendLinks&nbsp;-</h2>
        <div class="categories-card">
            @if (friendlinks.Success && friendlinks.Result.Any())
            {
                @foreach (var item in friendlinks.Result)
                {
                    <div class="card-item">
                        <div class="categories">
                            <a target="_blank" href="@item.LinkUrl">
                                <h3>@item.Title</h3>
                            </a>
                        </div>
                    </div>
                }
            }
            else
            {
                <ErrorTip />
            }
        </div>
    </div>
}

@code {
    /// <summary>
    /// friendlinks
    /// </summary>
    private ServiceResult<IEnumerable<FriendLinkDto>> friendlinks;

    /// <summary>
    /// 初始化
    /// </summary>
    protected override async Task OnInitializedAsync()
    {
        await Common.SetTitleAsync("友情链接");

        // 获取数据
        friendlinks = await Http.GetFromJsonAsync<ServiceResult<IEnumerable<FriendLinkDto>>>($"/blog/friendlinks");
    }
}